package com.hzdl.house_mgr.controller;


import com.hzdl.house_mgr.bean.Rent;
import com.hzdl.house_mgr.mapper.RentMapper;
import com.hzdl.house_mgr.service.AlipayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("payment")
public class PaymentController {

    @Autowired
    AlipayService alipayService;

    @Autowired
    RentMapper rentMapper;

    @RequestMapping("pay")
    public void payMent(HttpServletResponse response, HttpServletRequest request, String rentNum) {
        //通过订单号找价格
        Rent rent = rentMapper.findRentByNum(rentNum);
        Double price = rent.getPrice();
        String s = price.toString();
        try {

            System.out.println(rentNum);
            alipayService.aliPay(response,request,s,rentNum);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
